package top.wfzzq.ds.sort;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

/**
 * 自定义对象的排序
 * 
 * @author wanghui
 *
 */
public class StudentSortDemo {
	   public static  List<Student> makeRandom(){
		   Random random=new Random();
		   List<Student> list=new ArrayList<>();
		   for (int i = 0; i <10; i++) {
			list.add(new Student(random.nextInt(100),"name"+random.nextInt()));
		}
		   return list;
	   }
	   public static void showList(List<Student> list) {
		   System.out.println("==============================================");
		   for(Student student:list) {
			   System.out.println(student);
		   }
	   }
	   public static void main(String[] args) {
		List<Student> list=makeRandom();
		showList(list);
		//集合静态工具类，里面包含集合排序，乱序各种静态工具方法
		Collections.sort(list,new StudentComparator(1));
		showList(list);
		
		Collections.sort(list,new StudentComparator(2));
		showList(list);
	}
}
